package ar.edu.utn.frsf.tpae.a2012.g04.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

import ar.edu.utn.frsf.tpae.a2012.g04.dao.PagoDao;
import ar.edu.utn.frsf.tpae.a2012.g04.dominio.Pago;

public class PagoDaoHibernate implements PagoDao {

	 private SessionFactory sessionFactory = new AnnotationConfiguration()
     .configure().buildSessionFactory();
	 
	 

	
	@Override
	public Pago persistir(Pago pago) {
		Session session = sessionFactory.openSession();
	    session.beginTransaction();
	    session.saveOrUpdate(pago);
	    session.getTransaction().commit();
	    session.close();
	    return pago;
	}

	@Override
	public void eliminar(Pago pago) {
		Session session = sessionFactory.openSession();
	    session.beginTransaction();
	    session.delete(pago);
	    session.getTransaction().commit();
	    session.close();
	}

	@Override
	public List<Pago> listar() {
		Session session = sessionFactory.openSession();
	    Query query = session.createQuery("from " + Pago.class.getName());
	    List<Pago> list = query.list();
	    session.close();
		return list;
	}

	@Override
	public Pago buscarPorId(Pago id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void realizarPago(int numero, double monto, String comentario) {
		// TODO Auto-generated method stub
		
	}

}
